<%= javascript_include_tag "prototype" %>
<%= javascript_include_tag "util" %>
<%= javascript_include_tag "calendar" %>
<script>
        function checkNull(flag, msg_id, obj_id, msg_text){
                if (flag) {
                        if ($(obj_id).value == "")
                        {
                                $(msg_id).innerText = msg_text;
                                $(msg_id).style.display = "block";
                                return false;
                        }
                        else return true;
                }
                else {
                        $(msg_id).style.display = "none";
                }
        }
        function checkNum(flag, msg_id, obj_id, msg_text){
                if (flag) {
                        if ($(obj_id).value != "" && ! digCheck($(obj_id).value))
                        {
                                $(msg_id).innerText = msg_text;
                                $(msg_id).style.display = "block";
                                return false;
                        }
                        else return true;
                }
                else {
                        $(msg_id).style.display = "none";
                }
        }
        function checkFloat(flag, msg_id, obj_id, msg_text){
                if (flag) {
                        if ($(obj_id).value != "" && ! floatCheck($(obj_id).value))
                        {
                                $(msg_id).innerText = msg_text;
                                $(msg_id).style.display = "block";
                                return false;
                        }
                        else return true;
                }
                else {
                        $(msg_id).style.display = "none";
                }
        }
        function checkPrice(flag, msg_id, obj_id, msg_text){
                if (flag) {
                        if ($(obj_id).value != "" && ! yuanCheck($(obj_id).value))
                        {
                                $(msg_id).innerText = msg_text;
                                $(msg_id).style.display = "block";
                                return false;
                        }
                        else return true;
                }
                else {
                        $(msg_id).style.display = "none";
                }
        }

        function CheckForm(){
                return checkNull(true,'id_serial','product_serial','请输入品名规格') 
                                && checkNull(true,'id_name','product_name','请输入导针规格')
                                && checkFloat(true,'id_total_counts','product_total_counts','数量输入错误')
                                //&& checkPrice(true,'id_in_price','product_in_price','价格输入错误') 
                               // && checkPrice(true,'id_agent_price','product_agent_price','价格输入错误')
                                && checkPrice(true,'id_sale_price','product_sale_price','价格输入错误')
                               // && checkPrice(true,'id_announce_price','product_announce_price','价格输入错误')
                                //&& checkPrice(true,'id_total_counts','product_total_counts','数量输入错误')
                                ;
        }

</script>
<h1>产品管理 - <span id="secondHeading">增加产品</span></h1>
<form id="input-form" action="/product/add_product" enctype="multipart/form-data" method="post" onsubmit="return CheckForm()">
<TABLE border="0" id="INPUT_TABLE">
	<TR>
		<TD colspan="2">
			<% if @flash[:notice] -%>
			<div id="notice"><%= @flash[:notice] %></div>
			<% end -%>
		</TD>
	</TR>
	<!--<TR title="进货厂家">
		<TD>厂商：</TD>
		<TD><input id="product_factory" name="product[factory]" size="30" type="text" value=""  maxlength="20"/></TD>
	</TR>
	<TR title="产品品牌">
		<TD>品牌：</TD>
		<TD><input id="product_brand" name="product[brand]" size="30" type="text" value="" maxlength="20" /></TD>
                </TR>-->
	<TR title="入货型号">
		<TD>品名规格：</TD>
		<TD><input id="product_serial" name="product[serial]" size="30" type="text" value="" maxlength="20"  onfocus="checkNull(false,'id_serial')" onblur="checkNull(true,'id_serial',this.id,'请输入品名规格')"/>          <em>*</em><div class="redNsg" id="id_serial" style="display:none;"></div></TD>
	</TR>
	<TR title="出货型号">
		<TD>导针规格：</TD>
		<TD><input id="product_name" name="product[name]" size="30" type="text" value="" maxlength="20"  onfocus="checkNull(false,'id_name')" onblur="checkNull(true,'id_name',this.id,'请输入导针规格')"/>          <em>*</em><div class="redNsg" id="id_name" style="display:none;"></div></TD>
	</TR>
<TR title="F">
		<TD>F（槽宽）：</TD>
		<TD><input id="product_F" name="product[F]" size="30" TYPE="text" VALUE=""  maxlength="20" onfocus="checkFloat(false,'id_product_F')" onblur="checkFloat(true,'id_product_F',this.id,'输入错误')"/>（mm）<div class="redNsg" id="id_product_F" style="display:none;"></div></TD>
	</TR>
	<TR title="B">
		<TD>B（中径）：</TD>
		<TD><input id="product_B" name="product[B]" size="30" type="text" value="" maxlength="20" onfocus="checkFloat(false,'id_product_B')" onblur="checkFloat(true,'id_product_B',this.id,'输入错误')" />（mm）<div class="redNsg" id="id_product_B" style="display:none;"></div></TD>
                </TR>
                <TR title="P">
		<TD>P（脚距）：</TD>
		<TD><input id="product_P" name="product[P]" size="30" type="text" value="" maxlength="20" onfocus="checkFloat(false,'id_product_P')" onblur="checkFloat(true,'id_product_P',this.id,'输入错误')" />（mm）<div class="redNsg" id="id_product_P" style="display:none;"></div></TD>
                </TR>
<TR title="每个包装可以容纳产品的数量">
	<TD>入库数量：</TD>
		<TD><input id="product_total_counts" name="product[total_counts]" size="30" type="text" maxlength="20" onfocus="checkFloat(false,'id_total_counts')" onblur="checkFloat(true,'id_total_counts',this.id,'数量输入错误')"/>（kpcs）<div class="redNsg" id="id_total_counts" style="display:none;"></div></TD>
                </TR>
	<TR title="货品进入库房日期 格式2006-01-01">
		<TD>入库日期：</TD>
                <TD>
                        <script language=javascript>
                                var bir_Date=new dateSelector();
                                bir_Date.inputID='in_date_at';
                                bir_Date.inputName='product[in_date_at]';
                                bir_Date.display();
                        </script>
                </TD>
	</TR>
	<!--<TR title="进货价格">
		<TD>进货价格：</TD>
		<TD><input id="product_in_price" name="product[in_price]" size="30" type="text" value="0.00"  maxlength="20" onfocus="checkPrice(false,'id_in_price')" onblur="checkPrice(true,'id_in_price',this.id,'价格输入错误')"/>（人民币 元）<div class="redNsg" id="id_in_price" style="display:none;"></div></TD>
	</TR>
	<TR title="客户提货价格">
		<TD>代理价格：</TD>
		<TD><input id="product_agent_price" name="product[agent_price]" size="30" type="text" value="0.00" maxlength="20" onfocus="checkPrice(false,'id_agent_price')" onblur="checkPrice(true,'id_agent_price',this.id,'价格输入错误')" />（人民币 元）<div class="redNsg" id="id_agent_price" style="display:none;"></div></TD>
            </TR>-->
	<TR title="建议最低销售价格">
		<TD>单价：</TD>
		<TD><input id="product_sale_price" name="product[sale_price]" size="30" type="text" value="0.00" maxlength="20" onfocus="checkPrice(false,'id_sale_price')" onblur="checkPrice(true,'id_sale_price',this.id,'价格输入错误')" />（元）<div class="redNsg" id="id_sale_price" style="display:none;"></div></TD>
	</TR>
	<!--<TR title="媒体：网站 杂志公布的销售价格">
		<TD>媒体价格：</TD>
		<TD><input id="product_announce_price" name="product[announce_price]" size="30" type="text" value="0.00" maxlength="20" onfocus="checkPrice(false,'id_announce_price')" onblur="checkPrice(true,'id_announce_price',this.id,'价格输入错误')"/>（人民币 元）<div class="redNsg" id="id_announce_price" style="display:none;"></div></TD>
            </TR>-->
        <!--
	<TR title="进货总数量">
		<TD>进货总数量：</TD>
		<TD><input id="product_total_counts" name="product[total_counts]" size="30" type="text" value="0" maxlength="20"  onfocus="checkPrice(false,'id_total_counts')" onblur="checkPrice(true,'id_total_counts',this.id,'数量输入错误')"/>（个/箱）<div class="redNsg" id="id_total_counts" style="display:none;"></div></TD>
	</TR>
        -->
	<TR title="产品图片">
		<TD>产品图片1：</TD>
		<TD>
	      <%= file_column_field "productPicture", "picture1" %>
	     </TD>
	</TR>
	<TR title="产品图片">
		<TD>产品图片2：</TD>
		<TD>
	      <%= file_column_field "productPicture", "picture2" %>
	      </TD>
	</TR>
	<TR title="产品图片">
		<TD>产品图片3：</TD>
		<TD>
	      <%= file_column_field "productPicture", "picture3" %>
	      </TD>
	</TR>
	<TR title="产品图片">
		<TD>产品图片4：</TD>
		<TD>
	      <%= file_column_field "productPicture", "picture4" %>
	      </TD>
	</TR>
	<TR>
		<TD>产品图片5：</TD>
		<TD>
	      <%= file_column_field "productPicture", "picture5" %>
	      </TD>
	</TR>
	<TR>
		<TD>产品图片6：</TD>
		<TD>
	      <%= file_column_field "productPicture", "picture6" %>
	      </TD>
	</TR>
	<TR title="产品参数 等">
		<TD>产品介绍：</TD>
		<TD><%= text_area("product","argument",:cols=>"50",:rows=>"5")%></TD>
	</TR>
	<TR title="其他需要说明的">
		<TD>产品备注：</TD>
		<TD><%= text_area("product","memo",:cols=>"50",:rows=>"5")%></TD>
	</TR>
	<TR>
		<TD colspan="2" align="right">
			<input type="submit" value="添加" class="sub" onclick="return CheckForm()">&nbsp;OR&nbsp;<input type="reset" value="重新填写" class="cal"></TD>
	</TR>
</TABLE>
<p class="note"> <strong class="alert">注意：</strong><br/>
 一、有 <em>*</em> 标记的是必填项。
 </p>
</form>
